<?php

class BlogdapitiController extends Site_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        
        $this->titulo = 'Blog da Piti - '.$this->titulo;
    }

    public function indexAction()
    {
     
        Zend_Loader::loadClass('datetools','library');
        
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        
        $where = 'BLO_ID > 0 and ';
        
        // item
        $id = $this->_getParam('id', 0);
        $this->view->id = $id;
                
        // categoria
        $cat = $this->_getParam('cat', 0);
        if($cat > 0) $where = 'CTB_ID = '.$cat.' and ';
        
        // tag
        $tag = $this->_getParam('tag', 0);
        if($tag > '') $where = 'BLO_TAG like "'.$tag.'" and ';
        
        $query = 'SELECT SQL_CACHE * FROM BLOG WHERE '.$where.' BLO_STA = 1 ORDER BY BLO_DAT DESC'; // , BLO_HOR DESC 
        $obj = $db->fetchAll($query);
        //$this->view->blog = $obj;
        $this->view->blog = $this->paginacao($obj,30);
        
    }
    
    
    
   

}

